package com.example.demo.sensitive.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.demo.sensitive.dto.request.SensitiveWordRequest;
import com.example.demo.sensitive.dto.response.SensitiveWordResponse;
import com.example.demo.sensitive.entity.SensitiveWord;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @ClassName SensitiveWordService
 * @Description 敏感词服务接口
 * @Author System
 * @Date 2025/9/19
 **/
public interface SensitiveWordService extends IService<SensitiveWord> {

    /**
     * 分页查询敏感词
     */
    Page<SensitiveWordResponse> getPageList(int current, int size, String category, Integer status, String keyword);

    /**
     * 根据ID查询敏感词
     */
    SensitiveWordResponse getById(Long id);

    /**
     * 创建敏感词
     */
    Long create(SensitiveWordRequest request);

    /**
     * 更新敏感词
     */
    void update(Long id, SensitiveWordRequest request);

    /**
     * 删除敏感词
     */
    void delete(Long id);

    /**
     * 批量删除敏感词
     */
    void batchDelete(List<Long> ids);

    /**
     * 启用/禁用敏感词
     */
    void updateStatus(Long id, Integer status);

    /**
     * 批量更新状态
     */
    void batchUpdateStatus(List<Long> ids, Integer status);

    /**
     * 根据分类查询敏感词
     */
    List<SensitiveWordResponse> getByCategory(String category);

    /**
     * 查询所有启用的敏感词
     */
    List<SensitiveWordResponse> getEnabledWords();

    /**
     * 统计各分类的敏感词数量
     */
    List<CategoryStatistics> getCategoryStatistics();

    /**
     * 批量导入敏感词
     */
    ImportResult batchImport(MultipartFile file);

    /**
     * 导出敏感词
     */
    byte[] export(String category, Integer status);

    /**
     * 获取默认敏感词库
     */
    List<SensitiveWordResponse> getDefaultKeywords();

    /**
     * 分类统计内部类
     */
    @Data
    class CategoryStatistics {
        private String category;
        private Integer count;
        private Integer enabledCount;
    }

    /**
     * 导入结果内部类
     */
    @Data
    class ImportResult {
        private Integer total;
        private Integer success;
        private Integer failed;
        private List<String> errorMessages;
    }
}
